<script lang="ts">
  import { Select as SelectPrimitive } from "bits-ui"
  import CaretSort from "svelte-radix/CaretSort.svelte"
  import { cn } from "$lib/utils.js"

  type $$Props = SelectPrimitive.TriggerProps
  type $$Events = SelectPrimitive.TriggerEvents

  let className: $$Props["class"] = undefined
  export { className as class }
</script>

<SelectPrimitive.Trigger
  class={cn(
    "border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus:outline-none focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
    className,
  )}
  {...$$restProps}
>
  <slot />
  <div>
    <CaretSort class="h-4 w-4 opacity-50" />
  </div>
</SelectPrimitive.Trigger>
